﻿using System;
using fit;

namespace ScrumBox.AcceptanceTests.HelloWorld
{
    public class CardValidator
    {
        public static bool IsValid(CreditCardDTO cc)
        {
            return (cc.cardNumber.Length == 16 && cc.postCode.Length > 4 && cc.owner.Length > 5);
        }
    }

    public class CreditCardDTO
    {
        public String cardNumber;
        public String owner;
        public String postCode;
    }


    public class CardValidationTest : ColumnFixture
    {
        private readonly ExtendedCreditCardDTO card = new ExtendedCreditCardDTO();

        public override object GetTargetObject()
        {
            return card;
        }

        private class ExtendedCreditCardDTO : CreditCardDTO
        {
            /// <summary>
            /// The extended object needs to also provide the test methods.
            /// The data comes from its base class i.e. CreditCardDTO but since its acting 
            /// like a ColumnFixture we need a way to call the methods also. i.e. isValid()
            /// </summary>
            /// <returns></returns>
            public bool isValid()
            {
                return CardValidator.IsValid(this);
            }
        }
    }
}